const http = require("http")

http.createServer((req, res) => {
    let body = [];
    req.on('error', (err) => {
        console.error(err);
    }).on('data', (chunk) => {
        body.push(chunk);
    }).on('end', () => {
        body = Buffer.concat(body).toString();
        console.log(body);
        res.setHeader('Content-Type', 'text/html')
        res.setHeader('X-Foo', 'bar')
        res.writeHead(200, { 'Content-Type': 'text/plain' })
        res.end(`<html maa=a>
        <head>
            <style>
                body div #myid {
                    width: 100px;
                    background-color: aquamarine;
                }
                body div img {
                    width: 30px;
                    background-color: brown;
                }
            </style>
        </head>
        <body>
            <div>
                <img id="myid" />
                <img />
            </div>
        </body>
        </html>`)
    });
}).listen('8088')

console.log('server started');